package com.ws.utils.base;

/**
 * @ClassName YthResCodeEnum
 * @Description 一体化返回码枚举类
 * @Author zhengchenggong
 * @Date 2020/7/15 4:39 下午
 * @Version 1.0
 **/
public class YthResCodeEnum {

    //成功的枚举
    public enum Success {
        CODE0000("0000", "处理成功");

        public String getCode() {
            return code;
        }

        public String getMsg() {
            return msg;
        }

        private String code;

        private String msg;

        private Success(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }
    }

    //失败的枚举
    public enum Error {
        CODE0001("0001", "接收失败"),
        CODE0200("0200", "用户密码不正确"),
        CODE0201("0201", "报文签名非法"),
        CODE0300("0300", "操作不存在或数量不一致"),
        CODE0301("0301", "金额格式错误"),
        CODE0302("0302", "存在非法字符"),
        CODE0303("0303", "字符长度超长"),
        CODE0400("0400", "没有匹配到社保提供的单位"),
        CODE0401("0401", "基础数据不存在"),
        CODE0402("0402", "明细数据与汇总数据不符"),
        CODE0403("0403", "Payid已存在，请检查是否重复发送，错误id"),
        CODE0404("0404", "没有匹配到社保提供的付款账户"),
        CODE0405("0405", "没有匹配到社保提供的支出功能分类"),
        CODE0406("0406", "没有匹配到社保提供的资金性质"),
        CODE0407("0407", "其它未定义错误");

        public String getCode() {
            return code;
        }

        public String getMsg() {
            return msg;
        }

        public static String getMsg(String code) {
            Error[] values = values();
            for (Error err : values) {
                if (err.code.equals(code)) {
                    return err.msg;
                }
            }
            return null;
        }

        private String code;

        private String msg;

        private Error(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }
    }


}
